
/***
 *  async/await
 *  await 关键字可以 ”暂停“ async function 执行
 *  await 关键字可以获取resolve或reject的返回值
 *  await 可以让try catch捕获到异步回调抛出的错误
 */


(function () {
    const result = async function () {
        try {
            const content = await new Promise((resolve, reject) => {
                setTimeout(() => {
                    reject('promise reject');
                }, 500);
            });
        } catch (e) {
            console.log('error', e)
        }
    }();

    setTimeout(() => {
        console.log(result, 'result')
    }, 800);

})();

